/**
 * description: //TODO
 *
 * @author: heliming
 * @date:2019/06/23 下午 10:55
 */
public class Money {
  public static void main(String[] args) {
    System.out.println(longToUpperYMB(12335223262154354L));
  }
  private static final int CNUNITINDEXINIT= 0;
  private static final int CNUNITINDEXTOYUAN= 3;
  private static final int CNAMOUNTINIT= 0;
  private static final int CNAMOUNTPLACE= 10;
  /**
   * 输入一个long类型的RMB转为为大写RMB。要求long最后一位对应金额的分
   * @param CNAmount
   * @return
   */

  public static String longToUpperYMB(long CNAmount){
    String [] CN_UPPER_NUMBER = new String[] {"零","壹","贰","叄","肆","伍","陆","柒","扒","玖"};
    String [] CN_UPPER_UNIT = new String[] {"分","角","元","拾","佰","仟","万","拾","佰","仟","亿"};
    String RMB = "";
    int CNUnitIndex = CNUNITINDEXINIT;
    while (CNAmount>CNAMOUNTINIT){
      RMB = (CN_UPPER_NUMBER[(int) (CNAmount%CNAMOUNTPLACE)]+CN_UPPER_UNIT[CNUnitIndex++])+RMB;
      CNAmount /= CNAMOUNTPLACE;
      if(CNUnitIndex>CN_UPPER_UNIT.length-1){
        CNUnitIndex = CNUNITINDEXTOYUAN;
      }
    }

    return RMB;
  }
}
